#pragma once

#include <vector>
#include "Point.h"
#include "EventHandler.h"

typedef void* WINID;

class IWindow
{
public:
	IWindow();
	
	virtual bool Create( const char* title, int width, int height, bool fullscreen ) = 0;
	virtual void Destroy() = 0;
	virtual void Messages() = 0;
	virtual int Callback( unsigned int uMsg, unsigned int wParam, long lParam ) = 0;
	inline WINID GetHandle()
	{
		return m_handle;
	};
	inline WINID GetInstance()
	{
		return m_instance;
	};
	inline bool& Quit()
	{
		return m_quit;
	};
	inline Maths::Point<>& Size()
	{
		return m_size;
	};
	inline bool* Keys()
	{
		return UserInput::keys;
	};
	virtual void ReceiveMessage( IEvent& event );
	virtual void RegisterHandler(const HashedString& eventType, Pointer<EventHandler> handler);
	virtual void RemoveHandler(const HashedString& eventType, void* handler);
protected:
	class UserInput
	{
		friend IWindow;
	public:
		static bool keys[256];
		static unsigned int mouseButtons;
		static Maths::Point<> mousePosition;
	};
	WINID m_handle;
	WINID m_instance;
	
	Maths::Point<> m_size;
	bool m_quit;
	bool m_active;
	bool m_fullscreen;
	bool m_mouseDown;
	
	EventHandler::Map_t m_eventHandlers;
};